<?php
// +----------------------------------------------------------------------
// | ZGUAN [ 致力于帮助更多的中小企业实现低成本数字化转型 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.zguan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ZGUAN 并不是自由软件，未经许可不能去掉ZGUAN 相关版权
// +----------------------------------------------------------------------
// | Author: ZGUAN Team <admin@zguan.cn>  0769-82282996  15899929162
// +----------------------------------------------------------------------
namespace app\validate\bill;

use think\Validate;

class BillCatalogValidate extends Validate
{
    protected $rule = [
        'energy_name|设备名称' => 'require',
        'plan_id|计费方案' => 'require|number',
        'bill_id|账单信息' => 'require|number',
        'cate_id|费用类别' => 'require|number',
        'amount|费用金额' => 'require|float',
        'beilv|设备倍率' => 'require|number',
        'energy_type|设备类型' => 'require|in:11,12,13,14',
        'start_date|计费开始日期' => 'require',
        'end_date|计费结束日期' => 'require|gt:start_date',
    ];

    public function sceneAdd()
    {
        return $this->remove('id', 'require')
            ->remove('beilv', 'require')
            ->remove('plan_id', 'require')
            ->remove('energy_type', 'require')
            ->remove('energy_name', 'require');
    }

    public function sceneAddBasic()
    {
        return $this->remove('id', 'require')
            ->remove('beilv', 'require')
            ->remove('plan_id', 'require')
            ->remove('energy_type', 'require')
            ->remove('energy_name', 'require');
    }

    public function sceneAddEnergy()
    {
        return $this->remove('id', 'require')
            ->remove('amount', 'require');
    }

    public function scenePayment()
    {
        return $this->only(['pay_method', 'pay_amount'])
            ->append('pay_method|支付方式', 'require|in:1,2,3,4,5')
            ->append('pay_amount|支付金额', 'require|float');
    }

    public function sceneAddReduced()
    {
        return $this->remove('id', 'require')
            ->remove('beilv', 'require')
            ->remove('plan_id', 'require')
            ->remove('energy_type', 'require')
            ->remove('energy_name', 'require')
            ->remove('start_date', 'require')
            ->remove('end_date', 'require');
    }

    public function sceneEdit()
    {
        return $this->only(['amount']);
    }

    public function sceneEditEnergy()
    {
        return $this->only(['plan_id', 'beilv'])
            ->remove('beilv', 'requireWith:plan_id')
            ->remove('plan_id', 'requireWith:energy_type');
    }

    public function sceneDel()
    {
        return $this->only(['id'])->append('id', 'require|number');
    }
}